package com.example.condition;

import com.example.condition.service.ShowCmdService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;
import java.util.Set;

/**
 * Condition @Conditional
 */
public class Example {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext =
                new AnnotationConfigApplicationContext(ConditionConfig.class);

        Map<String, ShowCmdService> beans = applicationContext.getBeansOfType(ShowCmdService.class);
        Set<String> keys = beans.keySet();
        System.out.println(keys);

        ShowCmdService cmdService = applicationContext.getBean(ShowCmdService.class);
        String cmdName = cmdService.cmdName("dir");
        System.out.println("cmdName = " + cmdName);
    }
}
